package me.send.produce.data.controller;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import me.send.business.base.Pager;
import me.send.data.service.pojo.Role;
import me.send.data.service.service.RoleService;
import me.send.data.service.service.TreeService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

@Controller
@RequestMapping(value = "role")
public class RoleController {

	@Autowired
	private RoleService roleService;

	@Autowired
	private TreeService treeService;

	@RequestMapping(value = "page")
	@ResponseBody
	public Map<String, Object> page(Pager pager, Role role) {
		return roleService.page(pager, role);
	}

	// 查询分页数据
	@RequestMapping(value = "role/list")
	public ModelAndView order_list(HttpServletRequest request) {
		// 如果这个连接 和 树里面的链接是一样的 那就替换一下
		ModelAndView modelAndView = new ModelAndView(
				"/stage/role/role_list");
		// session.setAttribute("LoadTree", treeService.main_tree(0, request,
		// "broker/broker/list"));
		modelAndView.addObject("LoadTree",
				treeService.main_tree(0, request, "role/role/list"));
		modelAndView.addObject("module", "角色管理");
		return modelAndView;
	}
	
	// 编辑数据 角色管理 2015年7月8日10:46:09
	@RequestMapping("role/edit")
	@ResponseBody
	public Map<String, Object> rule_edit(Role role) {
		return roleService.role_edit(role);
	}
	
	@RequestMapping("batch/delete")
	@ResponseBody
	public Map<String, Object> batch_delete(String roleids){
		return roleService.batch_delete(roleids);
	}

}
